package com.example.syyao.myapp.WebContact;

import android.content.Context;
import android.net.ConnectivityManager;
import android.net.NetworkInfo;

public class NetUtils {

	public static final String SUCCESS = "success";
	public static final String FAIL = "fail";

	public static String SERVER_IPADDR = "10.0.2.2";
	public static int SERVER_PORTNO = 8080;


	public static String SERVER_URL_STUDENT_SERVLET = "http://" + SERVER_IPADDR
			+ ":" + SERVER_PORTNO + "/MyWeb/Login?time1="
			+ System.currentTimeMillis();

	private NetUtils() {
		/* cannot be instantiated */
		throw new UnsupportedOperationException("cannot be instantiated");
	}

	public static boolean isConnected(Context context) {

		ConnectivityManager connectivity = (ConnectivityManager) context
				.getSystemService(Context.CONNECTIVITY_SERVICE);

		if (null != connectivity) {

			NetworkInfo info = connectivity.getActiveNetworkInfo();
			if (null != info && info.isConnected()) {
				if (info.getState() == NetworkInfo.State.CONNECTED) {
					return true;
				}
			}
		}
		return false;
	}

}